from selenium import webdriver
from selenium.webdriver.common.by import By


class Client:
    def __init__(self):
        self.wd = webdriver.Chrome()
        self.wd.get("http://49.233.108.117:3000/signin")


    def action(self, element, **kwargs):
        ac = kwargs.get("action")
        if ac == 'send_keys':
            self.wd.find_element(*element).send_keys(kwargs.get('value'))
        elif ac == 'click':
            self.wd.find_element(*element).click()
        else:
            print("action输入错误， 请检查输入")


if __name__ == "__main__":
    client = Client()
    client.action((By.ID, 'name'), action = 'send_keys', value="test1")
    client.action((By.ID, "pass"), action = 'send_keys',value ='123456')
    client.action((By.XPATH, '//input[@value = "登录"]'),action = 'click')